/*
 *  AParamList.cpp
 *  libavid
 *
 *  Created by Peter on 29.02.12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#include "AParamList.h"
#include "AStream.h"

A_IMPLEMENT_CLASS( 'PRLS', AParamList, AObject );

void AParamList::readFromStream( AStream& str, const AObjDoc& objd )
{
	UInt8 tagMark, version;
	str.readPod( tagMark );
	str.readPod( version );
	TR_ASSERT( tagMark == 0x02 );
	TR_ASSERT( version == 0x01 );
	
	Int32 numItems;
	str.readPod( numItems );
	TR_ASSERT( numItems >= 0 );
	_paramItems.clear(); // FIXME: Potetial mem leak
	
	for( int i = 0; i < numItems; ++i ) {
		UInt32 item;
		str.readPod( item ); // TODO: Resolve to AParamItem* via AObjDoc
		_paramItems.push_back( item );
	}
	
	str.readPod( tagMark );
	TR_ASSERT( tagMark == 0x03 );
}

void AParamList::dump( std::ostream& str ) const
{
	str << "AParamList {" << std::endl;
	
	str << "\t_paramItems[ " << _paramItems.size() << " ] {" << std::endl;
	
	ParamItemList::const_iterator it = _paramItems.begin();
	
	for( ; it != _paramItems.end(); ++it ) {
		str << "\t\t" << *it << std::endl;
	}
	
	str << "\t}" << std::endl;
	
	str << "}" << std::endl;
}